﻿//-----------------------------------------------------------------
//
// @(#)$Id: Parcel.cs,v 1.0 2014/01/02 16:10:51 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2014/01/02 16:10:51 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using System.Data.SqlClient;

namespace ebay.Dal
{
  
    public class Parcel
    {
        ///<summary>
        ///
        ///</summary>
        public DataTable GetParcelOrder(String eBayUserID, String orderID)
        {
            String sqlString = @"SELECT DISTINCT p.BuyerFullName AS BuyerID,p.BuyerAddress1 + ' '  + p.BuyerAddress2 as BuyerStreect,p.BuyerCity,p.BuyerCountry,p.BuyerPostCode AS BuyerZipCode,p.BuyerPhoneNumber AS BuyerTelephone,p.BuyerEmail,p.Parcel_ID AS ParcelID,p.DispatchDate,p.My_PostageService AS ShippingService,ISNULL(p.memo, 'Royalmail') AS ShippingServiceBusseness,ISNULL(t.No_plate,'') AS TrackingNo,p.TotalWeight AS ShippingServiceWeight,p.TotalPrice AS ShippingServiceCost FROM ParcelPrint p LEFT JOIN ParcelPrintTrackingNumber t ON p.parcel_id=t.c_barcode WHERE p.eBayUserID=@eBayUserID AND p.OrderID=@OrderID AND p.printed='y'";
            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter() { ParameterName = "@eBayUserID", SqlDbType = SqlDbType.NVarChar, Size = 80, Value = eBayUserID },
                new SqlParameter() { ParameterName = "@OrderID", SqlDbType = SqlDbType.NVarChar, Size = 30, Value = orderID }
            };
      
            DataTable table = SqlHelper.ExecuteDataTable(SqlHelper.ceterDB_Conn, CommandType.Text, sqlString, parameters);
            return table;
        }
    }
}
